<template>
	<view style="width:100%;height:100%;">
		    <view class="flex-col justify-start relative page">
      <view class="flex-col items-start section">
        <view class="flex-row justify-evenly group_2">
          <img
            class="image_5"
            src="static/aimages/tou.png"
          />
          <img
            class="image_5"
            src="static/aimages/tou.png"
          />
          <img
            class="image_5"
            src="static/aimages/tou.png"
          />
          <img
            class="image_5"
            src="static/aimages/tou.png"
          />
          <img
            class="image_5"
            src="static/aimages/tou.png"
          />
          <img
            class="image_5"
            src="static/aimages/tou.png"
          />
          <img
            class="image_5"
            src="static/aimages/tou.png"
          />
        </view>
        <view class="flex-row justify-between group_2">
          <view class="flex-row">
            <img
              class="image_5"
              src="static/aimages/tou.png"
            />
            <img
              class="image_5"
              src="static/aimages/tou.png"
            />
            <img
              class="image_5"
              src="static/aimages/tou.png"
            />
          </view>
          <view class="flex-row">
            <img
              class="image_5"
              src="static/aimages/tou.png"
            />
            <img
              class="image_5"
              src="static/aimages/tou.png"
            />
            <img
              class="image_5"
              src="static/aimages/tou.png"
            />
          </view>
        </view>
      </view>
      <img
        class="image_6 pos_17"
        src="static/newimage/img_00.png"
      />
      <view class="flex-col section_2 pos_18">
        <view class="flex-col items-center group_3">
          <text class="text_2">{{ userInfo.username }}</text>
          <!-- text class="font text_3 mt-10-5">退出登录</text-->
        </view>
          <view class="flex-col group_11 mt-24-5">
            <!-- <view class="flex-col section_3">
              <view class="flex-row justify-between items-center" @click="clickHref(5)">
                <view class="flex-row items-center">
                  <img
                    class="shrink-0 image_8"
                    src="static/aimages/yifaxin.png"
                  />
                  <text class="ml-14 font_4">已发短信</text>
                </view>
                <img
                  class="image_9 image_10"
                  src="static/aimages/djiantou.png"
                />
              </view>
              </view> -->
              <view class="flex-col section_3" @click="clickHref(6)">
              <view class="flex-row justify-between items-center">
                <view class="flex-row items-center">
                  <img
                    class="shrink-0 image_11"
                    src="static/aimages/dianhua.png"
                  />
                  <text class="ml-12 font_4 text_11">人工传话</text>
                </view>
                <img
                  class="image_9 image_12"
                  src="static/aimages/djiantou.png"
                />
              </view>
            </view>
            <view class="mt-10 flex-row justify-between items-center section_4">
              <view class="flex-col group_12">
                <view @click="cnotactUs" class="flex-row items-center self-stretch">
                  <img
                    class="image_13"
                    src="static/aimages/kefu.png"
                  />
                  <text class="font_4 text_12 ml-12-5">联系我们</text>
                </view>
              </view>
              <view @click="copyPhone(kefu)" class="flex-col justify-start items-center text-wrapper"><text class="text_13">复制号码</text></view>
            </view>
			<view @click="handleLogout" class="mt-10 flex-row justify-between items-center section_4">
			  <view class="flex-col group_12">
			    <view @click="cnotactUs" class="flex-row items-center self-stretch">
			      <img
			        class="image_13"
			        src="static/image/icon_09.png"
			      />
			      <text class="font_4 text_12 ml-12-5">退出登录</text>
			    </view>
			  </view>
			</view>
          </view>
        </view>
      </view>
	</view>
</template>

<script>
	import {
	  getToken,
	  removeToken
	} from '@/utils/auth'
	import { getNotice,  getUserinfo } from '@/api/index'
	
	export default {
		onLoad() {
		  uni.setNavigationBarTitle({
		    title: '我的', 
		  });
		},
		data() {
			return {
				kefu:'', //客服号码
				userInfo: {}
			}
		},
		onShow() {
			this.getUserinfo()
			this.getNotice()
		},
		methods: {
			// 此页面js功能主要为号码复制 跳转 已处理
			//以下注释为源代码 未处理
			
			     // const hdata = JSON.parse(localStorage.getItem('sharedData'));
			     //    var kefu;
			     //    CoreUtil.ajax("/miniApp/getKefu.nf",{asdfg:hdata.asdfg},function (ret) {
			     //       kefu=ret.data.kefu;
			     //       $("#kefu").html(kefu);
			     //    });
			
			
		// 获取电话公告
		getNotice() {
			const params = {
				type: 3
			}
			getNotice(params).then(res => {
				const { code, data } = res;
				console.log(333333, data)
				if (code === 200) {
					this.kefu = data.content || '';
				}
				
			})
		},
		getUserinfo() {
			getUserinfo().then(res => {
				console.log(876, res)
				const { code, data } = res;
				if (code === 200) {
					this.userInfo = data.userInfo;
				}
			})
		},
		//后面得自己再配置路由
		clickHref(type) {
			let url = "";
			if (type == 5) {
				url = "/pages/messageOrder/messageOrder";
			} else if (type == 6) {
				url = "/pages/rgchOrder/rgchOrder";
			} 
			
			if (url) {
				uni.navigateTo({
					url: url
				});
			}
		},
		// 复制号码
		copyPhone(phone) {
		  uni.setClipboardData({
			data: phone, 
			success: () => {
		   
			  uni.showToast({
				title: '复制成功',
				icon: 'none', 
				duration: 2000
			  });
			},
			fail: (err) => {
			  uni.showToast({
				title: '复制失败，请重试',
				icon: 'none',
				duration: 2000
			  });
			  console.error('复制失败：', err);
			}
		  });
		},
		cnotactUs() {
			uni.showModal({
				title: '客服号码',
				content: this.kefu || '暂无客服信息',
				showCancel: false
			});
		},
		handleLogout() {
			uni.showModal({
			  title: '提示',
			  content: '确定退出登录吗？',
			  showCancel: true,
			  success: (res) => {
			    if (res.confirm) {
			      if (res.confirm) {
			        removeToken()
			        uni.reLaunch({
			          url: "/pages/login/login"
			        });
			      }
			    }
			  }
			});
		}
	}
	}
	
</script>

<style>
@import url("/static/newcss/my.css");
@import url("/static/newcss/common.css");
</style>
